<!DOCTYPE html>
<html> 
<head> 
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>同步日志</title> 
    <link rel="shortcut icon" href="favicon.ico">
	<#import "/common/import.ftl" as import>
    <@import.tableManagerImportCss/>
    <link href="${WEB_PATH}/resources/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
 	<style>
    	.demo:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "条件查询：";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.demo {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		}
		.account:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "异常日志信息";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.account {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		    margin-top: 10px;
		}
	    .json:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "实体JSON";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.json {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		    margin-top: 10px;
		}
	    .exception:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "异常信息";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.exception {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		    margin-top: 10px;
		}
		.company:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "日志信息";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.company {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		}
		.search{
		    width:300px;
		}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>同步日志</h5>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">  
                    <div class="col-sm-12">
                        <!-- Example Events -->
                        <div class="example-wrap"> 
                                <table id="exampleTableEvents" >
                                    <thead>
                                         <tr>
                                            <th data-field="id" data-visible = "false" >id</th>  
								            <th data-field="startDate" data-formatter="formatTime">同步开始时间</th> 
								            <th data-field="endDate" data-formatter="formatTime">同步结束时间</th>
								            <th data-field="syTotal">同步数据总数</th>
								            <th data-field="successNum" data-formatter="formatStatus">成功数量</th>
								            <th data-field="failNum" data-formatter="formatType">失败数量</th>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                        <!-- End Example Events -->
                    </div>
                </div>
            </div>
        </div>
        <!-- End Panel Other -->
    </div>
    
    <div id="aut_win"></div>
    <@import.tableManagerImportScript/>
    <script src="${WEB_PATH }/resources/js/plugins/fancybox/jquery.fancybox.js"></script>
    <script src="${WEB_PATH}/resources/js/city-picker.data.js"></script>
	<script src="${WEB_PATH}/resources/js/city-picker.js"></script>
    <script >
    	$(function(){
    		$("#JYJGIDS").chosen({width:'100%'});
    		$("#JYXZDIDS").chosen({width:'100%'}); 
    		$("#JCFFIDS").chosen({width:'100%'});
    		
    		$(window).resize(function () {
		        $('#exampleTableEvents').bootstrapTable('resetView');
		    });
		   
		    function queryParams(params) {
		        var temp = {  
			        limit: params.limit,  
			        offset: params.offset, 
			        JYJGBH:$("#JYJGBH").val(),
			        JCXBH:$("#JCXBH").val(),
			        JYJGIDS:  $("#JYJGIDS").val() != null ? $("#JYJGIDS").val().join(","):$("#JYJGIDS").val(),
			        JYXZDIDS: $("#JYXZDIDS").val() != null ? $("#JYXZDIDS").val().join(","):$("#JYXZDIDS").val(),
			        JCFFIDS: $("#JCFFIDS").val() != null ? $("#JCFFIDS").val().join(","):$("#JCFFIDS").val(),
			        maxrows: params.limit,
			        pageindex:params.pageNumber,
		        };
		        return temp;
			}
    		//加载table数据
	    	$("#exampleTableEvents").bootstrapTable({
	            url: "${WEB_PATH }/reg/synchronizationlog/getPage.do",
	            method: 'get',
	            search:true,
	            pagination:true,
	            pageNumber:1,  
	            pageSize:10,   
	            showRefresh:true, 
	            showColumns:true,
	            detailView:true,
	            iconSize: "outline",
	            toolbar: "#exampleTableEventsToolbar",
	            sidePagination: "server", //设置为服务器端分页
	            queryParams: queryParams,//参数
	            minimumCountColumns: 1, 
	            search: false,    //隐藏搜索框
	            clickToSelect: true,
	            onExpandRow:subTableFormatter,  
	        });
	        
	        $('input.form-control.input-outline').attr("placeholder","请输入商户名称/联系人/联系人电话"); //设置搜索提示信息
	        
        });
        
        function subTableFormatter(index, row, $detail){
			var info = $detail.html('<div id="info"></div>').find('#info');
			info.load("${WEB_PATH}/reg/synchronizationlog/view/detail.do?id="+row.id,function(){
				if(row.failNum>0){
					$("#account").show();
				}else{
					$("#account").hide();
				}
				
				//加载table数据
		    	$("#exampleTableEvents1").bootstrapTable({
		            url: "${WEB_PATH }/reg/synchronizationlog/getExceptionPage.do?synchronizationLogId="+row.id,
		            method: 'get',
		            search:false,
		            pagination:true,
		            pageNumber:1,  
		            pageSize:10,   
		            showRefresh:false, 
		            showColumns:false,
		            detailView:true,
		            iconSize: "outline",
		            toolbar: "#exampleTableEventsToolbar",
		            sidePagination: "server", //设置为服务器端分页
		            queryParams: queryParams,//参数
		            minimumCountColumns: 1, 
		            search: false,    //隐藏搜索框
		            clickToSelect: true,
		            onExpandRow:subTableFormatter_1,  
		        });
				
			});
			
	       function queryParams(params) {
		        var temp = {  
			        limit: params.limit,  
			        offset: params.offset, 
			        JYJGBH:$("#JYJGBH").val(),
			        JCXBH:$("#JCXBH").val(),
			        JYJGIDS:  $("#JYJGIDS").val() != null ? $("#JYJGIDS").val().join(","):$("#JYJGIDS").val(),
			        JYXZDIDS: $("#JYXZDIDS").val() != null ? $("#JYXZDIDS").val().join(","):$("#JYXZDIDS").val(),
			        JCFFIDS: $("#JCFFIDS").val() != null ? $("#JCFFIDS").val().join(","):$("#JCFFIDS").val(),
			        maxrows: params.limit,
			        pageindex:params.pageNumber,
		        };
		        return temp;
			}
			
		}
		
		function subTableFormatter_1(index, row, $detail){
			var info = $detail.html('<div id="info"></div>').find('#info');
			info.load("${WEB_PATH}/reg/synchronizationlog/view/detailException.do?id="+row.id);
		}
        
         //点击查询搜索
		$("#search").click(function(){
			$("#exampleTableEvents").bootstrapTable('refresh');
		});
        
        
        
        function success(result){  
			if(result.success == true){ 
				swal({
			        title: "操作成功",
			        text: result.msg
		    	})
		    	$("#exampleTableEvents").bootstrapTable('refresh');
			}else{
				$('#saveBut').attr("disabled",false);    
				swal({
			        title: "操作失败",
			        text: result.msg
		    	})
			}
		}
		
		
		function formatterStatus(val){
			var auditName = "";
			if(val == "1"){
				auditName = '<span class="label label-primary">正常</span>';
			}else if(val == "2"){
				auditName = '<span class="label label-warning">停用</span>';
			}else if(val == "3"){
				auditName = '<span class="label label-danger">断网</span>';
			} else if(val == "4"){
				auditName = '<span class="label label-danger">注销</span>';
			} 
        	return auditName;
		} 
		
		function formatActionType(val){
			if(val == "add"){
				return '<span class="label label-success">新增</span>';
			}else if(val == "update"){
				return '<span class="label label-success">更新</span>';
			}
		}
		
	   function formatterStatus1(val){
			var auditName = "";
			if(val == "JCJBXX"){
				auditName = "检验基本信息";
			}else if(val == "SDS"){
				auditName = "双怠速";
			}else if(val == "WTGK"){
				auditName = "稳态工况";
			} else if(val == "JYST"){
				auditName = "简易瞬态";
			} else if(val == "JZJS"){
				auditName = "加载减速";
			} else if(val == "BTGYD"){
				auditName = "不透光烟度";
			}else if(val == "LZYD"){
				auditName = "滤纸烟度";
			} else if(val == "HBJCJG"){
				auditName = "检验机构";
			}else if(val == "JGJCS"){
				auditName = "检测线";
			}else if(val == "PFCBCX"){
				auditName = "超标车型";
			}else if(val == "WGCL"){
				auditName = "违规车辆";
			}else if(val == "GLBM"){
				auditName = "管理部门";
			}else if(val == "XXFB"){
				auditName = "信息发布";
			}      
        	return '<span class="label label-primary">'+auditName+'</span>';
		}
				
	   function formatStatus(val){
		  return '<span class="label label-primary">'+val+'</span>';
		}
		
		
		function formatType(val){
		 	return '<span class="label label-danger">'+val+' </span>';
		}
		
        function formatTime(val){
		 	var tt=new Date(val).Format("yyyy-MM-dd hh:mm:ss");
    		return tt; 
		}
		
		Date.prototype.Format = function (fmt) { //author: meizz 
		    var o = {
		        "M+": this.getMonth() + 1, //月份 
		        "d+": this.getDate(), //日 
		        "h+": this.getHours(), //小时 
		        "m+": this.getMinutes(), //分 
		        "s+": this.getSeconds(), //秒 
		        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
		        "S": this.getMilliseconds() //毫秒 
		    };
		    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		    for (var k in o)
		    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		    return fmt;
		}
		
		
		
		
		//点击新增按钮
		$("#add").click(function(){
			layer.open({
			      type: 2,
			      title: '<span style="color: #ed5565">新增检测线</span>',
			      shadeClose: false, 
			      shade: 0.3,
			      maxmin: false, //开启最大化最小化按钮
			      area: ['75%', '75%'],
			      content: "${WEB_PATH }/reg/tsline/view/add.do",
			      btn: ['确定','取消'],
			      yes: function(index, layero){
				      var body = layer.getChildFrame('body', index);
				      var iframeWin = window[layero.find('iframe')[0]['name']];
				      iframeWin.saveAddForm();
				  },
				  cancel: function(){
					  layer.closeAll();
				  }
			});
		});
		
		
	     //点击修改按钮
		$("#edit").click(function(){
		    var selectRow = $("#exampleTableEvents").bootstrapTable('getSelections');
            var tsLine = selectRow[0]; 
        	if(1 != selectRow.length){
			    layer.msg('请选择您需要修改的检测线信息！', {icon: 5}); 
			    return ;
	       	} 
			layer.open({
			      type: 2,
			      title: '<span style="color: #ed5565">修改检测线</span>',
			      shadeClose: false, 
			      shade: 0.3,
			      maxmin: false, //开启最大化最小化按钮
			      area: ['75%', '75%'],
			      content: "${WEB_PATH }/reg/tsline/view/edit.do?id="+tsLine.ID,
			      btn: ['确定','取消'],
			      yes: function(index, layero){
				      var body = layer.getChildFrame('body', index);
				      var iframeWin = window[layero.find('iframe')[0]['name']];
				      iframeWin.saveEditForm();
				  },
				  cancel: function(){
					  layer.closeAll();
				  }
			});
		});
		
		
		 //删除检测机线
	     $('#del').click(function () {
        	var selectRow = $("#exampleTableEvents").bootstrapTable('getSelections');
        	if(0 == selectRow.length){
			    layer.msg('请选择您需要删除的检测机构信息！', {icon: 5}); 
			    return ;
        	}
        	
        	layer.confirm('<span style="color: red">您确定要删除该数据?</span>',{icon: 3, title:'系统提示',btn: ['确认','取消']},
    		function(){
        		$.yilinAjax({
				   	  	type:'GET',
				   	  	url:'${WEB_PATH }/reg/tsline/del.do?id=' + selectRow[0].ID, 
				   	  	data:null,
	            		errorcallback:null,
	            		successcallback:success
				});
			});
		});
        
    </script>
</body>

</html>